package com.bw.sofa_module.detail.adapter;

import android.view.View;
import android.widget.ImageView;

import com.alibaba.android.arouter.facade.annotation.Autowired;
import com.alibaba.android.arouter.launcher.ARouter;
import com.bw.adapter_sdk.quick.BaseQuickAdapter;
import com.bw.adapter_sdk.quick.BaseViewHolder;
import com.bw.common.provider.LoginProvider;
import com.bw.sofa_module.R;
import com.bw.sofa_module.detail.entity.RecommentData;

import java.text.SimpleDateFormat;

public class DetailAdapter extends BaseQuickAdapter<RecommentData> {
    private int userId;
    private SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    public DetailAdapter(int userId) {
        super(R.layout.item_detail);
        this.userId = userId;
        addItemChildClick(R.id.item_detail_delete);
    }

    @Override
    public void convert(BaseViewHolder holder, RecommentData item) {
        holder.setText(R.id.item_detail_artist,item.author.name);
        holder.setText(R.id.item_detail_content,item.commentText);
        holder.setCirImage(R.id.item_detail_artist_img,item.author.avatar);
        holder.setText(R.id.item_detail_time,simpleDateFormat.format(item.createTime));
        ImageView image = holder.getView(R.id.item_detail_delete);
        if (userId == item.userId)
            image.setVisibility(View.VISIBLE);
        else
            image.setVisibility(View.GONE);

    }
}
